package com.qf.j2105.service.impl;

import com.qf.j2105.mapper.UserInfoMapper;
import com.qf.j2105.po.UserInfo;
import com.qf.j2105.service.UserInfoService;
import com.qf.j2105.vo.LoginInfoVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserInfoServiceImpl implements UserInfoService {
    @Resource
    private UserInfoMapper userInfoMapper;

    @Override
    public UserInfo login(LoginInfoVo loginInfo) {
        System.out.println("loginInfo = " + loginInfo);
        System.out.println(loginInfo.getUname());
        UserInfo userInfo1 = userInfoMapper.selectByname(loginInfo.getUname());
        System.out.println("userInfo1 = " + userInfo1);
//        UserInfo userInfo = userInfoMapper.selectByname(loginInfo.getUname());
//        System.out.println("userInfo = " + userInfo);
        if (userInfo1 != null && userInfo1.getPass().equals(loginInfo.getPass())) {
            return userInfo1;
        } else {
            return null;
        }

    }

    @Override
    public boolean insert(UserInfo userInfo) {
        int i = userInfoMapper.insertUser(userInfo);
        if (i > -1) {
            return true;
        } else {
            return false;
        }

    }
}
